/**
 * 
 */
package org.student.impl;

import java.util.List;

import org.springframework.stereotype.Component;
import org.student.dao.ITeacherInfoDao;
import org.student.entity.StuSys_Teacher;

@Component("ITeacherInfoDaoImpl")
public class ITeacherInfoDaoImpl extends HibernateDaoImpl implements ITeacherInfoDao {

/**
 */
	@Override
	public boolean insert(StuSys_Teacher tea) throws Exception{
		super.getHibernateTemplate().save(tea);
		return true;
	}

	/**
	 */
	@Override
	
	public List<StuSys_Teacher> getAllTeacher() throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find("from StuSys_Teacher");
	}
	
	@Override
	public List<StuSys_Teacher> getTeachersById(String id) throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find("from StuSys_Teacher where id = " + id);
			
	}
	@Override
	public List<StuSys_Teacher> getTeachersByClass(String className)
			throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find("from StuSys_Teacher where classInfo.className = '" + className+ "'");
	}
	@Override
	public List<StuSys_Teacher> getTeachersByInsititue(String insititueName)
			throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find(
				"from StuSys_Teacher where classInfo.insititueName = '"
						+ insititueName + "'");
	}

	@Override
	public List<StuSys_Teacher> getTeachersByName(String name) throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find(
				"from StuSys_Teacher where teachName like '%" + name + "%'");
	}
	@Override
	public List<StuSys_Teacher> getTeachersByWords(String words)
			throws Exception {
		
		return (List<StuSys_Teacher>) super.getHibernateTemplate().find(
				"from StuSys_Teacher where teachName like '%" + words
						+ "%' or createDate like '%" + words
						+ "%' or sex like '%" + words
						+ "%' or address like '%" + words + "%' or tel like '%"
						+ words + "%' or nation like '%" + words
						+ "%' or classInfo.className like '%" + words
						+ "%' or classInfo.manager like '%" + words
						+ "%' or classInfo.specialtyName like '%" + words
						+ "%' or classInfo.insititueName like '%" + words
						+ "%' or classInfo.memo like '%" + words + "%' ");
	}

	@Override
	public void deleteTeacher(int id) throws Exception {
		this.delete(StuSys_Teacher.class, id) ;
		
	}
	@Override
	public void updateTeacher(StuSys_Teacher sub) throws Exception {
		this.update(sub);
		
	}



}
